<template>
  <div class="node-manage">
    <el-tabs v-model="activeName" @tab-click="handleClick" class="tab-wrap">
      <el-tab-pane :label="item.label" :name="item.name" v-for="item in tabs" :key="item.name">
      </el-tab-pane>
    </el-tabs>
    <div class="main-wrap">
      <keep-alive>
        <component :is="activeName" ref="child"></component>
      </keep-alive>
    </div>
  </div>
</template>
<script>
  import ivrAnnouncementNodeLink from './nodeManage/ivrAnnouncementNodeLink.vue'
  import ivrTextAnnouncementNodeLink from './nodeManage/ivrTextAnnouncementNodeLink.vue'
  import ivrIvrNodeLink from './nodeManage/ivrIvrNodeLink.vue'
  import ivrValidationNodeLink from './nodeManage/ivrValidationNodeLink.vue'
  import ivrAssignmentNodeLink from './nodeManage/ivrAssignmentNodeLink.vue'
  import encryptMd5NodeLink from './nodeManage/encryptMd5NodeLink.vue'
  import ivrRouteNodeLink from './nodeManage/ivrRouteNodeLink.vue'
  import ivrCallUrlNodeLink from './nodeManage/ivrCallUrlNodeLink.vue'
  import ivrDateNodeLink from './nodeManage/ivrDateNodeLink.vue'
  import ivrVoiceMailNodeLink from './nodeManage/ivrVoiceMailNodeLink.vue'
  import ivrRoomNodeLink from './nodeManage/ivrRoomNodeLink.vue'
  import ivrSatisfactionNodeLink from './nodeManage/ivrSatisfactionNodeLink.vue'
  import ivrExtensionPeerNodeLink from './nodeManage/ivrExtensionPeerNodeLink.vue'
  import ivrWebcallPeerNodeLink from './nodeManage/ivrWebcallPeerNodeLink.vue'
  import ivrAsrPeerNodeLink from './nodeManage/ivrAsrPeerNodeLink.vue'
  import ivrSuperDialJobNumNodeLink from './nodeManage/ivrSuperDialJobNumNodeLink.vue'
  import ivrMenuNodeLink from './nodeManage/ivrMenuNodeLink.vue'
  import ivrSystemNodeLink from './nodeManage/ivrSystemNodeLink.vue'
  export default {
    name: 'nodeManage',
    data () {
      return {
        activeName: 'ivrAnnouncementNodeLink',  //   当前模块变量
        tabs: [
          {name: 'ivrAnnouncementNodeLink', label: '播放语音节点'},
          {name: 'ivrTextAnnouncementNodeLink', label: '播放文本节点'},
          {name: 'ivrIvrNodeLink', label: '按键菜单节点'},
          {name: 'ivrValidationNodeLink', label: '采集输入节点'},
          {name: 'ivrAssignmentNodeLink', label: '赋值节点'},
          {name: 'encryptMd5NodeLink', label: 'MD5加密节点'},
          {name: 'ivrRouteNodeLink', label: '按变量路由节点'},
          {name: 'ivrCallUrlNodeLink', label: 'CallUrl节点'},
          {name: 'ivrDateNodeLink', label: this.$t('configLazyLoad.process.node8')},
          {name: 'ivrVoiceMailNodeLink', label: '留言节点'},
          {name: 'ivrRoomNodeLink', label: '会议室节点'},
          {name: 'ivrSatisfactionNodeLink', label: '自定义满意度节点'},
          {name: 'ivrExtensionPeerNodeLink', label: '自定义节点'},
          {name: 'ivrWebcallPeerNodeLink', label: '双向回呼节点'},
          {name: 'ivrAsrPeerNodeLink', label: '语音识别节点'},
          {name: 'ivrSuperDialJobNumNodeLink', label: '采集工号并拨打节点'},
          {name: 'ivrMenuNodeLink', label: '转IVR菜单节点'},
          {name: 'ivrSystemNodeLink', label: this.$t('configLazyLoad.process.node')}
        ]
      }
    },
    components: {
      ivrAnnouncementNodeLink,
      ivrTextAnnouncementNodeLink,
      ivrIvrNodeLink,
      ivrValidationNodeLink,
      ivrAssignmentNodeLink,
      encryptMd5NodeLink,
      ivrRouteNodeLink,
      ivrCallUrlNodeLink,
      ivrDateNodeLink,
      ivrVoiceMailNodeLink,
      ivrRoomNodeLink,
      ivrSatisfactionNodeLink,
      ivrExtensionPeerNodeLink,
      ivrWebcallPeerNodeLink,
      ivrAsrPeerNodeLink,
      ivrSuperDialJobNumNodeLink,
      ivrMenuNodeLink,
      ivrSystemNodeLink
    },
    watch: {
      // 监听pbx变换触发子组件得刷新方法
      PBX () {
        let routerName = this.$route.meta.title
        if (routerName === 'nodeManage') {
          this.$refs.child.$refs.search.exportMethod('refresh')
        }
      }
    },
    computed: {
      PBX () {
        return this.$store.state.config.callCenter.currentPBX
      }
    },
    methods: {
      handleClick (tab) {
        this.activeName = tab.name
      }
    },
    beforeMount () {
    }
  }
</script>

<style lang="stylus" scoped>
  .node-manage
    .main-wrap
      padding 20px
      height calc(100vh - 174px)
      overflow scroll
      overflow-x hidden
</style>

